#!/bin/sh -efu

srcdir="$(readlink -ev ..)"
export PATH="$srcdir:$PATH"

unittest_use_color=1
unittest_hide_successful=1

[ -z "${VERBOSE:-${V:-}}" ] ||
	unittest_hide_successful=

. ../shell-unittest

WORKDIR=
setUpTests() {
	WORKDIR="$(mktemp -d "$PROG.XXXXXXXXX")"
}

tearDownTests() {
	rm -rf -- "$WORKDIR"
}

for s in \
	quote_sed_regexp quote_shell string_quote_remove \
	opt_check_dir opt_check_number opt_check_read \
	quote_sed_regexp_variable quote_shell_variable \
	getopt signal \
	fatal message verbose \
	quote_shell_args \
	ini_config_get ini_config_set ini_config_del ini_config_comment \
	git_config_foreach git_config_get git_config_count git_config_list git_config_set git_config_unset git_config_append \
	shell_var_unquote shell_var_trim \
	fill_mask \
	cmdline_foreach \
	cmdline_get \
	run_scripts \
	terminfo_init color_message color_text \
	create_temporary \
	json \
	;
do
	[ -z "${TEST-}" -o "${TEST-}" = "$s" ] ||
		continue
	. "./$s"
	registerTests "./$s"
done

runUnitTests
